/**
 * 
 */
package optimization.randomNumberGenerator;

import java.util.Random;

/**
 * This class provides a random number generator by using the {@link Random}
 * class.
 * 
 * @author Kevin Wagner
 * @version 1.0
 */
public class JavaRandomNumberGenerator extends RandomNumberGenerator {

	private Random r = new Random();
	
	/**
	 * Creates a new Java random number generator.
	 * @param seed 
	 */
	public JavaRandomNumberGenerator(long seed){
		super(seed);
		r=new Random(seed);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see optimization.randomNumberGenerator.RandomNumberGenerator#nextInt()
	 */
	@Override
	public int nextInt(int max) {
		return r.nextInt(max);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * optimization.randomNumberGenerator.RandomNumberGenerator#nextDouble()
	 */
	@Override
	public double nextDouble() {
		return r.nextDouble();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * optimization.randomNumberGenerator.RandomNumberGenerator#nextBoolean()
	 */
	@Override
	public boolean nextBoolean() {
		return r.nextBoolean();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see optimization.randomNumberGenerator.RandomNumberGenerator#nextLong()
	 */
	@Override
	public long nextLong() {
		return r.nextLong();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see optimization.randomNumberGenerator.RandomNumberGenerator#nextShort()
	 */
	@Override
	public short nextShort() {
		return (short) (r.nextInt(65536) - 32767);
	}

	/*
	 * (non-Javadoc)
	 * @see optimization.IdentificationI#getIndentification()
	 */
	@Override
	public String getIndentification() {
		return "Java Standard Random Number Generator";
	}

	/*
	 * (non-Javadoc)
	 * @see optimization.randomNumberGenerator.RandomNumberGenerator#nextGaussian()
	 */
	@Override
	public double nextGaussian() {
		return r.nextGaussian();
	}

	@Override
	public void setSeed(long seed) {
		this.setSeed(seed);
		r=new Random(seed);
		
	}


}
